define(function (require, exports, module) {
    return function (jQuery) {
        (function ($) {
            /*seajs-content-start*/
            var hotPointBusCtrl = function ($scope, httpservice) {
                $scope.listType =[{code:'0',name:"视频"},{code:'1',name:"音乐"}];
                $scope.selected = '0';

                $scope.checked = false;
                $scope.checkBoxClick = function(val)
                {
                    $scope.checked = val;
                };

                $scope.tabs1 = {
                    obj:''
                };

                $(".ratedetailbtn").live("click",function(e){
                    var serviceTypeCode = $(e.target).attr("data-id");
                    $scope.tabs1.obj.tabs('select', 1);

                    $("#starttime2").val($("#starttime1").val());
                    $("#endtime2").val($("#endtime1").val());
                    $scope.selected = serviceTypeCode;
                    $("#selectType").val(serviceTypeCode);

                    setInitPage();
                    var condition = {
                        starttime:$("#starttime1").val(),
                        endtime:$("#endtime1").val(),
                        pageindex:1,
                        pagesize:$scope.grid4.gridpagedata.pagesize,
                        servicetype:serviceTypeCode,
                        isprivate:$scope.checked
                    };

                    var f1 = getAllByType(condition);
                    var f2 = getAPPByType(condition);
                    var f3 = getWAPByType(condition);

                    $scope.$emit('loading', 'true');
                    $scope.$apply();
                    $.when(f1,f2,f3).then(function () {

                    }).always(function () {
                            $scope.$emit('loading', 'false');
                            $scope.$apply();
                        });

                });

                //删除下载文件
                $(".deletemodel").live("click",function(e){
                    var fileId = $(e.target).parent().attr("id");
                   if(confirm('你确定要删除该文件?')){
                       $.ajax({
                           url:httpservice.serverurl + "script/Common/DeleteTask",
                           type:"get",
                           data:{id:fileId},
                           dataType:"json",
                           success:function(result){
                               if(result.state){
                                   var condition = {
                                       mainmodule:"数据业务分析",
                                       submodule:"业务热点分析"
                                   }
                                   $scope.getDownloadList(condition);
                                   alert('删除成功!');
                               }
                               else{
                                   alert('删除失败!');
                               }
                           },
                           error:function(xmlHttpRequest,textStatus){
                               alert('请求出错!');
                           },
                           complete:function(xmlHttpRequest,textStatus){

                           }
                       });
                   }
                })

                var formatterServieType= function (cellvalue, options, rowObject) {
                    var listprint = "<button class='button ratedetailbtn' style='width:80px;height:20px;' data-id='" + rowObject.servicetypecode + "'>"+cellvalue+"</button>";
                    return listprint;
                };

                var formatterOperate = function(cellvalue, options, rowObject){
                    var listprint = "<button class='serviceTypebtn' style='width:80px;height:20px;' data-id='" + rowObject.servicetypecode + "'>导出用户明细</button>";
                    return listprint;
                };
                var formatterOperate1 = function(cellvalue, options, rowObject){
                    var listprint = "<button class='subServiceTypebtn' style='width:80px;height:20px;' data-id='" + rowObject.subservicetypecode + "'>导出用户明细</button>";
                    return listprint;
                };

                var downloadoperate = function(cellvalue, options, rowObject){
                    var listprint = "<a class='viewmodel' href='javascript:'id='"+rowObject.id+"' title = '查看'><img src='../../../images/chakan.png' /></a>" +
                        "<a class='downloadmodel' style='margin: 0 15px;' href= '"+httpservice.downloadurl+""+rowObject.filename+".csv' target='_blank' id='"+rowObject.id+"' state='"+rowObject.status+"' title='下载'><img src='../../../images/download.png' /></a>" +
                        "<a class='deletemodel' href='javascript:' id='"+rowObject.id+"' state='"+rowObject.state+"' title='删除'><img src='../../../images/delete1.png' /></a>";
                    return listprint;
                };

                $scope.grid1 = {
                    griddata: {
                        colnames: ['业务编码','业务类型','用户数', '点击数', '总流量(MB)', '日均用户数' ,"日均点击数","日均流量(MB)","人均流量(MB)","操作"],
                        colmodel: [
                            { name: 'servicetypecode', index: 'servicetypecode', sortable: false, sorttype: 'number', align:"center",hidden:true },
                            { name: 'servicetype', index: 'servicetype', sortable: false, align:"center",formatter:formatterServieType },
                            { name: 'usercount', index: 'usercount', sortable: true, sorttype: 'number', align:"center",hidden:true },
                            { name: 'clickcount', index: 'clickcount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'totallen', index: 'totallen', sortable: true, sorttype: 'number',align:"center"},
                            { name: 'dayucount', index: 'dayucount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'dayccount', index: 'dayccount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'daylen', index: 'daylen', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'peoplelen', index: 'peoplelen', sortable: true, sorttype: 'number', align:"center",hidden:true},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:formatterOperate}
                        ],
                        data: [
//                            { servicetypecode: "1",servicetype: "微信", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetypecode: "2",servicetype: "QQ", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetypecode: "3",servicetype: "微博", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetypecode: "4",servicetype: "邮箱", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 }
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(150);
                    }
                };

                $scope.grid2 = {
                    griddata: {
                        colnames: ['业务编码', '业务类型','用户数', '点击数', '总流量(MB)', '日均用户数' ,"日均点击数","日均流量(MB)","人均流量(MB)","操作"],
                        colmodel: [
                            { name: 'servicetypecode', index: 'servicetypecode', sortable: false, sorttype: 'number', align:"center",hidden:true },
                            { name: 'servicetype', index: 'servicetype', sortable: false, align:"center",formatter:formatterServieType },
                            { name: 'usercount', index: 'usercount', sortable: true, sorttype: 'number', align:"center",hidden:true },
                            { name: 'clickcount', index: 'clickcount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'totallen', index: 'totallen', sortable: true, sorttype: 'number',align:"center"},
                            { name: 'dayucount', index: 'dayucount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'dayccount', index: 'dayccount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'daylen', index: 'daylen', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'peoplelen', index: 'peoplelen', sortable: true, sorttype: 'number', align:"center",hidden:true},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:formatterOperate}
                        ],
                        data: [
//                            { servicetype: "微信", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "QQ", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "微博", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "邮箱", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 }
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(150);
                    }
                };

                $scope.grid3 = {
                    griddata: {
                        colnames: [ '业务编码','业务类型','用户数', '点击数', '总流量(MB)', '日均用户数' ,"日均点击数","日均流量(MB)","人均流量(MB)","操作"],
                        colmodel: [
                            { name: 'servicetypecode', index: 'servicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'servicetype', index: 'servicetype', sortable: false, align:"center",formatter:formatterServieType },
                            { name: 'usercount', index: 'usercount', sortable: true, sorttype: 'number', align:"center",hidden:true },
                            { name: 'clickcount', index: 'clickcount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'totallen', index: 'totallen', sortable: true, sorttype: 'number',align:"center"},
                            { name: 'dayucount', index: 'dayucount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'dayccount', index: 'dayccount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'daylen', index: 'daylen', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'peoplelen', index: 'peoplelen', sortable: true, sorttype: 'number', align:"center",hidden:true},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:formatterOperate}
                        ],
                        data: [
//                            { servicetype: "微信", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "QQ", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "微博", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "邮箱", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 }
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(150);
                    }
                };

                $scope.grid4 = {
                    gridpagedata:{
                        nowpage:1,
                        totalpage:1,
                        totalcount:20,
                        startline:1,
                        endline:20,
                        pagesize:20,
                        datacount:20,
                        pagelist:[20,50,100],
                        //第一页
                        toFirstpage: function(){
                            $scope.grid4.gridpagedata.nowpage=1;
                            $scope.turnPageAllByType();
                        },
                        //上一页
                        toToppage: function(){
                            if($scope.grid4.gridpagedata.nowpage>1){
                                $scope.grid4.gridpagedata.nowpage--;
                            }
                            $scope.turnPageAllByType();
                        },
                        //下一页
                        toNextpage: function(){
                            if($scope.grid4.gridpagedata.nowpage<$scope.grid4.gridpagedata.totalpage){
                                $scope.grid4.gridpagedata.nowpage++;
                            }
                            $scope.turnPageAllByType();
                        },
                        //最后一页
                        toLastpage: function(){
                            $scope.grid4.gridpagedata.nowpage = $scope.grid4.gridpagedata.totalpage;
                            $scope.turnPageAllByType();
                        },
                        //跳转到某一页
                        topage: function(){
                            if($scope.grid4.gridpagedata.nowpage<1)
                            {
                                $scope.grid4.gridpagedata.nowpage = 1;
                            }
                            if($scope.grid4.gridpagedata.nowpage>$scope.grid4.gridpagedata.totalpage){
                                $scope.grid4.gridpagedata.nowpage = $scope.grid4.gridpagedata.totalpage;
                            }
                            $scope.turnPageAllByType();
                        },
                        //改变页面显示记录数
                        changePagesize: function(){
                            $scope.grid4.gridpagedata.nowpage = 1;
                            $scope.turnPageAllByType();
                        }
                    },
                    griddata: {
                        colnames: ['类型编码','业务类型','业务编码','业务名称','用户数', '点击数', '总流量(MB)', '日均用户数' ,"日均点击数","日均流量(MB)","人均流量(MB)","操作"],
                        colmodel: [
                            { name: 'servicetypecode', index: 'servicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'servicetype', index: 'servicetype', sortable: false, align:"center" },
                            { name: 'subservicetypecode', index: 'subservicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'subservicetype', index: 'subservicetype', sortable: false, align:"center" },
                            { name: 'usercount', index: 'usercount', sortable: true, sorttype: 'number', align:"center",hidden:true },
                            { name: 'clickcount', index: 'clickcount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'totallen', index: 'totallen', sortable: true, sorttype: 'number',align:"center"},
                            { name: 'dayucount', index: 'dayucount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'dayccount', index: 'dayccount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'daylen', index: 'daylen', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'peoplelen', index: 'peoplelen', sortable: true, sorttype: 'number', align:"center",hidden:true},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:formatterOperate1}
                        ],
                        data: [
//                            { servicetype: "微信", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "QQ", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "微博", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "邮箱", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 }
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(150);
                    }
                };

                $scope.grid5 = {
                    gridpagedata:{
                        nowpage:1,
                        totalpage:1,
                        totalcount:20,
                        startline:1,
                        endline:20,
                        pagesize:20,
                        datacount:20,
                        pagelist:[20,50,100],
                        toFirstpage: function(){
                            $scope.grid5.gridpagedata.nowpage = 1;
                            $scope.turnPageAPPByType();
                        },
                        toToppage: function(){
                            if($scope.grid5.gridpagedata.nowpage>1){
                                $scope.grid5.gridpagedata.nowpage--;
                            }
                            $scope.turnPageAPPByType();
                        },
                        toNextpage: function(){
                            if($scope.grid5.gridpagedata.nowpage<$scope.grid5.gridpagedata.totalpage){
                                $scope.grid5.gridpagedata.nowpage++;
                            }
                            $scope.turnPageAPPByType();
                        },
                        toLastpage: function(){
                            $scope.grid5.gridpagedata.nowpage = $scope.grid5.gridpagedata.totalpage;
                            $scope.turnPageAPPByType();
                        },
                        topage: function(){
                            if($scope.grid5.gridpagedata.nowpage<1)
                            {
                                $scope.grid5.gridpagedata.nowpage = 1;
                            }
                            if($scope.grid5.gridpagedata.nowpage>$scope.grid5.gridpagedata.totalpage){
                                $scope.grid5.gridpagedata.nowpage = $scope.grid5.gridpagedata.totalpage;
                            }
                            $scope.turnPageAPPByType();
                        },
                        changePagesize: function(){
                            $scope.grid5.gridpagedata.nowpage = 1;
                            $scope.turnPageAPPByType();
                        }
                    },
                    griddata: {
                        colnames: ['类型编码', '业务类型','业务编码','业务名称','用户数', '点击数', '总流量(MB)', '日均用户数' ,"日均点击数","日均流量(MB)","人均流量(MB)","操作"],
                        colmodel: [
                            { name: 'servicetypecode', index: 'servicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'servicetype', index: 'servicetype', sortable: false, align:"center" },
                            { name: 'subservicetypecode', index: 'subservicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'subservicetype', index: 'subservicetype', sortable: false, align:"center" },
                            { name: 'usercount', index: 'usercount', sortable: true, sorttype: 'number', align:"center",hidden:true },
                            { name: 'clickcount', index: 'clickcount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'totallen', index: 'totallen', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'dayucount', index: 'dayucount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'dayccount', index: 'dayccount', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'daylen', index: 'daylen', sortable: true, sorttype: 'number', align:"center"},
                            { name: 'peoplelen', index: 'peoplelen', sortable: true, sorttype: 'number', align:"center",hidden:true},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:formatterOperate1}
                        ],
                        data: [
//                            { servicetype: "微信", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "QQ", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "微博", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "邮箱", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 }
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(150);
                    }
                };

                $scope.grid6 = {
                    gridpagedata:{
                        nowpage:1,
                        totalpage:1,
                        totalcount:20,
                        startline:1,
                        endline:20,
                        pagesize:20,
                        datacount:20,
                        pagelist:[20,50,100],
                        toFirstpage: function(){
                            $scope.grid6.gridpagedata.nowpage = 1;
                            $scope.turnPageWAPByType();
                        },
                        toToppage: function(){
                            if($scope.grid6.gridpagedata.nowpage>1){
                                $scope.grid6.gridpagedata.nowpage--;
                            }
                            $scope.turnPageWAPByType();
                        },
                        toNextpage: function(){
                            if($scope.grid6.gridpagedata.nowpage<$scope.grid6.gridpagedata.totalpage){
                                $scope.grid6.gridpagedata.nowpage++;
                            }
                            $scope.turnPageWAPByType();
                        },
                        toLastpage: function(){
                            $scope.grid6.gridpagedata.nowpage = $scope.grid6.gridpagedata.totalpage;
                            $scope.turnPageWAPByType();
                        },
                        topage: function(){
                            if($scope.grid6.gridpagedata.nowpage<1){
                                $scope.grid6.gridpagedata.nowpage = 1;
                            }
                            if($scope.grid6.gridpagedata.nowpage>$scope.grid6.gridpagedata.totalpage){
                                $scope.grid6.gridpagedata.nowpage = $scope.grid6.gridpagedata.totalpage;
                            }
                            $scope.turnPageWAPByType();
                        },
                        changePagesize: function(){
                            $scope.grid6.gridpagedata.nowpage = 1;
                            $scope.turnPageWAPByType();
                        }
                    },
                    griddata: {
                        colnames: ['类型编码', '业务类型','业务编码','业务名称','用户数', '点击数', '总流量(MB)', '日均用户数' ,"日均点击数","日均流量(MB)","人均流量(MB)","操作"],
                        colmodel: [
                            { name: 'servicetypecode', index: 'servicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'servicetype', index: 'servicetype', sortable: false, align:"center" },
                            { name: 'subservicetypecode', index: 'subservicetypecode', sortable: false, align:"center",hidden:true },
                            { name: 'subservicetype', index: 'subservicetype', sortable: false, align:"center" },
                            { name: 'usercount', index: 'usercount', sortable: true,sorttype: 'number', align:"center",hidden:true },
                            { name: 'clickcount', index: 'clickcount', sortable: true,sorttype: 'number', align:"center"},
                            { name: 'totallen', index: 'totallen', sortable: true, sorttype: 'number',align:"center"},
                            { name: 'dayucount', index: 'dayucount', sortable: true,sorttype: 'number', align:"center"},
                            { name: 'dayccount', index: 'dayccount', sortable: true,sorttype: 'number', align:"center"},
                            { name: 'daylen', index: 'daylen', sortable: true,sorttype: 'number', align:"center"},
                            { name: 'peoplelen', index: 'peoplelen', sortable: true,sorttype: 'number', align:"center",hidden:true},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:formatterOperate1}
                        ],
                        data: [
//                            { servicetype: "微信", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "QQ", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "微博", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 },
//                            { servicetype: "邮箱", usercount: 1000, clickcount:1000, "totallen":1000, "dayucount": 1000,dayccount:1000, daylen:1000,peoplelen:1000 }
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(150);
                    }
                };

                $scope.downloadList = {
                    gridpagedata:{
                        nowpage:1,
                        totalpage:1,
                        totalcount:20,
                        startline:1,
                        endline:20,
                        pagesize:20,
                        datacount:20,
                        pagelist:[20,50,100],
                        toFirstpage: function(){
                            $scope.downloadList1.gridpagedata.nowpage = 1;
                            $scope.turnPageWAPByType();
                        },
                        toToppage: function(){
                            if($scope.downloadList1.gridpagedata.nowpage>1){
                                $scope.downloadList1.gridpagedata.nowpage--;
                            }
                            $scope.turnPageWAPByType();
                        },
                        toNextpage: function(){
                            if($scope.downloadList1.gridpagedata.nowpage<$scope.downloadList1.gridpagedata.totalpage){
                                $scope.downloadList1.gridpagedata.nowpage++;
                            }
                            $scope.turnPageWAPByType();
                        },
                        toLastpage: function(){
                            $scope.downloadList1.gridpagedata.nowpage = $scope.downloadList1.gridpagedata.totalpage;
                            $scope.turnPageWAPByType();
                        },
                        topage: function(){
                            if($scope.downloadList1.gridpagedata.nowpage<1){
                                $scope.downloadList1.gridpagedata.nowpage = 1;
                            }
                            if($scope.downloadList1.gridpagedata.nowpage>$scope.downloadList1.gridpagedata.totalpage){
                                $scope.downloadList1.gridpagedata.nowpage = $scope.downloadList1.gridpagedata.totalpage;
                            }
                            $scope.turnPageWAPByType();
                        },
                        changePagesize: function(){
                            $scope.downloadList1.gridpagedata.nowpage = 1;
                            $scope.turnPageWAPByType();
                        }
                    },
                    griddata: {
                        colnames: ['ID','下载文件名', '创建时间','主模块','子模块','应用名称', '下载状态', '操作'],
                        colmodel: [
                            { name: 'id', index: 'id', sortable: false, align:"center",hidden:true },
                            { name: 'filename', index: 'filename', sortable: false, align:"center" },
                            { name: 'createtime', index: 'createtime', sortable: false, align:"center" },
                            { name: 'mainmodule',width:100, index: 'mainmodule', sortable: false, align:"center"},
                            { name: 'submodule',width:100, index: 'submodule', sortable: false, align:"center"},
                            { name: 'appname',width:100, index: 'appname', sortable: false,sorttype: 'number', align:"center"},
                            { name: 'status',width:100, index: 'status', sortable: false,sorttype: 'number', align:"center"},
                            { name: 'operate', index: 'operate', sortable: false, align:"center",formatter:downloadoperate}
                        ],
                        data: [
                            { "filename": "微信", "mainmodule": 1000, "submodule":1000, "appname":1000, "createtime": 1000,"status":1000, "operate":1000}
                          ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth(800);
                        grid.setGridHeight(300);
                    }
                };

                $scope.dialogList={
                    title:"下载列表",
                    ok:function(){},
                    cancel:function(){}
                };

                $scope.dataQuery1 = function(){
                    if($("#starttime1").val()==""){
                        alert('请选择开始时间!');
                        return false;
                    }
                    if($("#endtime1").val()==""){
                        alert('请选择结束时间!');
                        return false;
                    }
                    if(new Date($("#endtime1").val())<new Date($("#starttime1").val())){
                        alert('开始时间不能大于结束时间!');
                        return false;
                    }

                    queryData1();

                };

                $scope.dataQuery2 = function(){
                    if($("#starttime2").val()==""){
                        alert('请选择开始时间!');
                        return false;
                    }
                    if($("#endtime2").val()==""){
                        alert('请选择结束时间!');
                        return false;
                    }
                    if(new Date($("#endtime2").val())<new Date($("#starttime2").val())){
                        alert('开始时间不能大于结束时间!');
                        return false;
                    }
                    if($scope.selected==""){
                        alert('请选择业务类型!');
                        return false;
                    }
                    setInitPage();
                    queryData2();
                };

                $scope.showDownloadlist = function(){
                    $scope.dialogList.show();
                    var condition = {
                        mainmodule:"数据业务分析",
                        submodule:"业务热点分析"
                    }
                    $scope.getDownloadList(condition);
                    setInterval(function(){
                        $.ajax({
                            url:httpservice.serverurl + "script/Common/GetTaskList",
                            type:"post",
                            data:JSON.stringify(condition),
                            dataType:"json",
                            success:function(result){
                                $scope.downloadList.griddata.data = result.datas;
                                $scope.$apply();
                            },
                            error:function(xmlHttpRequest,textStatus){
                                alert("请求出错!");
                            },
                            complete:function(xmlhHttpRequest,textStatus){

                            }
                        });
                    },1000*60);
                }

                var setInitPage = function(){
                    $scope.grid4.gridpagedata.nowpage = 1;
                    $scope.grid5.gridpagedata.nowpage = 1;
                    $scope.grid6.gridpagedata.nowpage = 1;
                };

                var getAll = function(postdata){
                    return httpservice.post("script/DataBusiness/GetAll", JSON.stringify(postdata), function (result) {
                        $scope.grid1.griddata.data = result.datas;
                        $scope.$apply();
                    });
                };

                var getAPP = function(postdata){
                    return httpservice.post("script/DataBusiness/GetAPP", JSON.stringify(postdata), function (result) {
                        $scope.grid2.griddata.data = result.datas;
                        $scope.$apply();
                    });
                };

                $scope.getDownloadList = function(postdata){
                    $.ajax({
                        url:httpservice.serverurl + "script/Common/GetTaskList",
                        type:"post",
                        data:JSON.stringify(postdata),
                        dataType:"json",
                        success:function(result){
                            $scope.downloadList.griddata.data = result.datas;
                            $scope.$apply();
                        },
                        error:function(xmlHttpRequest,textStatus){
                            alert("请求出错!");
                        },
                        complete:function(xmlhHttpRequest,textStatus){

                        }
                    });
                }

                var getWAP = function(postdata){
                    return httpservice.post("script/DataBusiness/GetWAP", JSON.stringify(postdata), function (result) {
                        $scope.grid3.griddata.data = result.datas;
                        $scope.$apply();
                    });
                };

                var getAllByType = function(postdata){
                    return httpservice.post("script/DataBusiness/GetAllByType", JSON.stringify(postdata), function (result) {
                        $scope.grid4.gridpagedata.totalcount = result.recordCount;
                        $scope.grid4.gridpagedata.totalpage = result.pageCount;
                        $scope.grid4.gridpagedata.startline = result.startLine;
                        $scope.grid4.gridpagedata.endline = result.endLine;
                        $scope.grid4.gridpagedata.datacount = result.dataCount;
                        $scope.grid4.griddata.data = result.datas;
                        $scope.$apply();
                    });
                };

                var getAPPByType = function(postdata){
                    return httpservice.post("script/DataBusiness/GetAPPByType", JSON.stringify(postdata), function (result) {
                        $scope.grid5.gridpagedata.totalcount = result.recordCount;
                        $scope.grid5.gridpagedata.totalpage = result.pageCount;
                        $scope.grid5.gridpagedata.startline = result.startLine;
                        $scope.grid5.gridpagedata.endline = result.endLine;
                        $scope.grid5.gridpagedata.datacount = result.dataCount;
                        $scope.grid5.griddata.data = result.datas;
                        $scope.$apply();
                    });
                };

                var getWAPByType = function(postdata){
                    return httpservice.post("script/DataBusiness/GetWAPByType", JSON.stringify(postdata), function (result) {
                        $scope.grid6.gridpagedata.totalcount = result.recordCount;
                        $scope.grid6.gridpagedata.totalpage = result.pageCount;
                        $scope.grid6.gridpagedata.startline = result.startLine;
                        $scope.grid6.gridpagedata.endline = result.endLine;
                        $scope.grid6.gridpagedata.datacount = result.dataCount;
                        $scope.grid6.griddata.data = result.datas;
                        $scope.$apply();
                    });
                };

                $scope.queryAllByType = function(){
                    var querycondition = {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        pageindex:1,
                        pagesize:$scope.grid4.gridpagedata.pagesize,
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                    return getAllByType(querycondition);
                };

                $scope.queryAPPByType = function(){
                    var querycondition = {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        pageindex:1,
                        pagesize:$scope.grid5.gridpagedata.pagesize,
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                    return getAPPByType(querycondition);
                };

                $scope.queryWAPByType = function(){
                    var querycondition = {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        pageindex:1,
                        pagesize:$scope.grid6.gridpagedata.pagesize,
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                    return getWAPByType(querycondition);
                };

                $scope.turnPageAllByType = function(){
                    var pagecondition = {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        pageindex:$scope.grid4.gridpagedata.nowpage,
                        pagesize:$scope.grid4.gridpagedata.pagesize,
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                    var f1 = getAllByType(pagecondition);
                    $scope.$emit('loading', 'true');
                    $scope.$apply();
                    $.when(f1).then(function () {

                    }).always(function () {
                            $scope.$emit('loading', 'false');
                            $scope.$apply();
                        });
                };

                $scope.turnPageAPPByType = function(){
                    var pagecondition = {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        pageindex:$scope.grid5.gridpagedata.nowpage,
                        pagesize:$scope.grid5.gridpagedata.pagesize,
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                    var f1 = getAPPByType(pagecondition);
                    $scope.$emit('loading', 'true');
                    $scope.$apply();
                    $.when(f1).then(function () {

                    }).always(function () {
                            $scope.$emit('loading', 'false');
                            $scope.$apply();
                        });
                };

                $scope.turnPageWAPByType = function(){
                    var pagecondition = {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        pageindex:$scope.grid6.gridpagedata.nowpage,
                        pagesize:$scope.grid6.gridpagedata.pagesize,
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                    var f1 = getWAPByType(pagecondition);
                    $scope.$emit('loading', 'true');
                    $scope.$apply();
                    $.when(f1).then(function () {

                    }).always(function () {
                            $scope.$emit('loading', 'false');
                            $scope.$apply();
                        });
                };

                var queryData1 = function(){
                    var condition = getCondition();

                    var f1 = getAll(condition);
                    var f2 = getAPP(condition);
                    var f3 = getWAP(condition);

                    $scope.$emit('loading', 'true');
                    $scope.$apply();
                    $.when(f1,f2,f3).then(function () {

                    }).always(function () {
                            $scope.$emit('loading', 'false');
                            $scope.$apply();
                        });
                };

                var queryData2 = function(){
                    var f1 = $scope.queryAllByType();
                    var f2 = $scope.queryAPPByType();
                    var f3 = $scope.queryWAPByType();

                    $scope.$emit('loading', 'true');
                    $scope.$apply();
                    $.when(f1,f2,f3).then(function () {

                    }).always(function () {
                            $scope.$emit('loading', 'false');
                            $scope.$apply();
                        });
                };

                var getCondition = function(){
                    return {
                        starttime:$("#starttime1").val(),
                        endtime:$("#endtime1").val()
                    };
                };

                var getSubContidion = function(){
                    return {
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        servicetype:$scope.selected,
                        isprivate:$scope.checked
                    };
                };

                $scope.dateFormat = function (date, fmt) { //author: meizz
                    var o = {
                        "M+": date.getMonth() + 1,                 //月份
                        "d+": date.getDate(),                    //日
                        "h+": date.getHours(),                   //小时
                        "m+": date.getMinutes(),                 //分
                        "s+": date.getSeconds(),                 //秒
                        "q+": Math.floor((date.getMonth() + 3) / 3), //季度
                        "S": date.getMilliseconds()             //毫秒
                    };
                    if (/(y+)/.test(fmt))
                        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
                    for (var k in o)
                        if (new RegExp("(" + k + ")").test(fmt))
                            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    return fmt;
                };

                $(".jin1").live("click",(function(e){
                    var num = $(e.target).find("label").text();
                    $("#starttime1").attr("value", $scope.dateFormat(new Date(new Date().setDate(new Date().getDate() - num)), "yyyy-MM-dd"));
                    $("#endtime1").attr("value", $scope.dateFormat(new Date(new Date().setDate(new Date().getDate() - 1)), "yyyy-MM-dd"));

                    queryData1();

                }));

                $(".jin2").live("click",(function(e){
                    var num = $(e.target).find("label").text();
                    $("#starttime2").attr("value", $scope.dateFormat(new Date(new Date().setDate(new Date().getDate() - num)), "yyyy-MM-dd"));
                    $("#endtime2").attr("value", $scope.dateFormat(new Date(new Date().setDate(new Date().getDate() - 1)), "yyyy-MM-dd"));
                    setInitPage();
                    queryData2();

                }));

                $scope.init=function(){
                    //$scope.$emit('loading', 'true');
                    var f = httpservice.getJSON("script/Common/GetServiceType",null,function(data){
                        if(data!=null){
                            $("#selectType").children("option").remove();
                            for(var i=0;i<data.length;i++){
                                $("#selectType").append("<option value='"+data[i].code+"'>"+data[i].name+"</option>")
                            }
                        }
                        $scope.listType = data;
                        $scope.selected = $scope.listType[0].code;
                        $scope.$apply();
                    }).complete(function(){
//                            $("#starttime1").val($scope.dateFormat(new Date(new Date().setDate(new Date().getDate() - 1)), "yyyy-MM-dd"));
//                            $("#endtime1").val($scope.dateFormat(new Date(new Date().setDate(new Date().getDate() - 1)), "yyyy-MM-dd"));
//                            var condition = getCondition();
//
//                            var f1 = getAll(condition);
//                            var f2 = getAPP(condition);
//                            var f3 = getWAP(condition);
//
//                            $.when(f1,f2,f3).then(function () {
//
//                            }).always(function () {
//                                    $scope.$emit('loading', 'false');
//                                    $scope.$apply();
//                                });
                        });
                };

                $scope.init();

                $scope.change = function(e){
//                    $scope.selected = e.selected;
                    alert($scope.selected);
                    console.log($scope.selected);
                };

                document.selectTypeChange = function(e){
                    $scope.selected = e.value;
                };

                /*文件下载*/
                var downloadAllServiceType = function (postdata) {
                    $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/SubmitAllServiceTypeDownloadTask",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            //var url = httpservice.serverurl + 'script/DataBusiness/DownLoadAllServiceType?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            //window.open(url, '_self');
                            if(result){
                                alert('提交下载任务成功!');
                            }
                            else{
                                alert("提交下载任务失败!");
                            }
                        },
                        error:function(xmlHttpRequest,textStatus){
                            alert("请求出错!");
                        },
                        complete:function(xmlHttpRequest,textStatus){

                        }
                    });
                };

                var downloadAPPServiceType = function (postdata) {
                    $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/SubmitAPPServiceTypeDownloadTask",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            //var url = httpservice.serverurl + 'script/DataBusiness/DownLoadAPPServiceType?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            //window.open(url, '_self');
                            if(result){
                                alert("提交下载任务成功!");
                            }
                            else{
                                alert("提交下载任务失败!");
                            }
                        },
                        error:function(xmlHttpRequest,textStatus){
                            alert("请求出错!");
                        },
                        complete:function(xmlHttRequest,textStatus)
                        {

                        }
                    });
                };

                var downloadWAPServiceType = function (postdata) {
                    $.ajax({
                        url:httpservice.serverurl + "script/DataBusiness/SubmitWAPServiceTypeDownloadTask",
                        type:"POST",
                        data:JSON.stringify(postdata),
                        dataType:"json",
                        success:function(result){
                            if(result){
                                alert("提交下载任务成功!");
                            }
                            else{
                                alert("提交下载任务失败!");
                            }
                        },
                        error:function(xmlHttpRequest,textStatus){
                            alert("请求出错!");
                        },
                        complete:function(xmlHttpRequest,textStatus){

                        }
                    });
                };

                var downloadAllSubServiceType = function (postdata) {
                    return $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/UpLoadAllSubServiceType",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            var url = httpservice.serverurl + 'script/DataBusiness/DownLoadAllSubServiceType?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            window.open(url, '_self');
                        }
                    });
                };

                var downloadAPPSubServiceType = function (postdata) {
                    return $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/UpLoadAPPSubServiceType",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            var url = httpservice.serverurl + 'script/DataBusiness/DownLoadAPPSubServiceType?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            window.open(url, '_self');
                        }
                    });
                };

                var downloadWAPSubServiceType = function (postdata) {
                    return $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/UpLoadWAPSubServiceType",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            var url = httpservice.serverurl + 'script/DataBusiness/DownLoadWAPSubServiceType?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            window.open(url, '_self');
                        }
                    });
                };

                var downloadUserDetailByServiceType = function (postdata) {
                    return $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/UpLoadUserDetailByServiceType",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            var url = httpservice.serverurl + 'script/DataBusiness/DownLoadUserDetail?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            window.open(url);
                        }
                    });
                };

                var downloadUserDetailBySubServiceType = function (postdata) {
                    return $.ajax({
                        url: httpservice.serverurl + "script/DataBusiness/UpLoadUserDetailBySubServiceType",
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            var url = httpservice.serverurl + 'script/DataBusiness/DownLoadUserDetail?fileId=' + result.FileId + '&fileName=' + result.FileName; //转向网页的地址;
                            window.open(url);
                        }
                    });
                };

                //提交下载任务
                var submitDownloadTask = function (postdata,posturl) {
                    $.ajax({
                        url: posturl,
                        type: "POST",
                        data: JSON.stringify(postdata),
                        dataType: "json",
                        success: function (result, textStatus) {
                            if(result.state){
                                alert('提交下载任务成功!');
                            }
                            else{
                                alert("提交下载任务失败,\r\n"+result.error);
                            }
                        },
                        error:function(xmlHttpRequest,textStatus){
                            alert("请求出错!");
                        },
                        complete:function(xmlHttpRequest,textStatus){

                        }
                    });
                };

                $scope.exportdata1 = function(){
                    var condition = getCondition();
                    condition.mainmodule = "数据业务分析";
                    condition.submodule = "业务热点分析";
                    condition.appname = "类型分析";
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitAllServiceTypeDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadAllServiceType(condition);
                };
                $scope.exportdata2 = function(){
                    var condition = getCondition();
                    condition.mainmodule = "数据业务分析";
                    condition.submodule = "业务热点分析";
                    condition.appname = "类型分析";
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitAPPServiceTypeDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadAPPServiceType(condition);
                };
                $scope.exportdata3 = function(){
                    var condition = getCondition();
                    condition.mainmodule = "数据业务分析";
                    condition.submodule = "业务热点分析";
                    condition.appname = "类型分析";
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitWAPServiceTypeDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadWAPServiceType(condition);
                };
                $scope.exportdata4 = function(){
                    var condition = getSubContidion();
                    condition.mainmodule = "数据业务分析";
                    condition.submodule = "业务热点分析";
                    condition.appname = "业务分析";
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitAllSubServiceTypeDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadAllSubServiceType(condition);
                };
                $scope.exportdata5 = function(){
                    var condition = getSubContidion();
                    condition.mainmodule = "数据业务分析";
                    condition.submodule = "业务热点分析";
                    condition.appname = "业务分析";
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitAPPSubServiceTypeDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadAPPSubServiceType(condition);
                };
                $scope.exportdata6 = function(){
                    var condition = getSubContidion();
                    condition.mainmodule = "数据业务分析";
                    condition.submodule = "业务热点分析";
                    condition.appname = "业务分析";
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitWAPSubServiceTypeDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadWAPSubServiceType(condition);
                };

                $(".serviceTypebtn").live("click",function(e){
                    var serviceType = $(this).attr("data-id");
                    var condition ={
                        starttime:$("#starttime1").val(),
                        endtime:$("#endtime1").val(),
                        servicetype:serviceType,
                        mainmodule:"数据业务分析",
                        submodule:"业务热点分析",
                        appname:"类型分析"
                    };

                    var url = httpservice.serverurl + "script/DataBusiness/SubmitServiceTypeUserDetailDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadUserDetailByServiceType(condition);
                });

                $(".subServiceTypebtn").live("click",function(e){
                    var subServiceType = $(this).attr("data-id");
                    var condition ={
                        starttime:$("#starttime2").val(),
                        endtime:$("#endtime2").val(),
                        subservicetype:subServiceType,
                        mainmodule:"数据业务分析",
                        submodule:"业务热点分析",
                        appname:"业务分析"
                    };
                    var url = httpservice.serverurl + "script/DataBusiness/SubmitSubServiceTypeUserDetailDownloadTask";
                    submitDownloadTask(condition,url);
                    //downloadUserDetailBySubServiceType(condition);
                });
            };
            var lv3BusCtrl = function ($scope, httpservice) {
                var users;
                var reads;
                var len;
                var abledown=false;
                var downcondition;
                var dateFormat = function (date, fmt) { //author: meizz
                    var o = {
                        "M+": date.getMonth() + 1,                 //月份
                        "d+": date.getDate(),                    //日
                        "h+": date.getHours(),                   //小时
                        "m+": date.getMinutes(),                 //分
                        "s+": date.getSeconds(),                 //秒
                        "q+": Math.floor((date.getMonth() + 3) / 3), //季度
                        "S": date.getMilliseconds()             //毫秒
                    };
                    if (/(y+)/.test(fmt))
                        fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
                    for (var k in o)
                        if (new RegExp("(" + k + ")").test(fmt))
                            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    return fmt;
                };
                $scope.highchartline = {
                    chartdata: {
                        chart: {
                            height: 400,
                            type: 'bar'
                        },
                        title: {
                            text: ''
                        },
                        xAxis: {
                            gridLineWidth: 1,
                            lineColor: '#000',
                            tickColor: '#000',
                            labels: {
                                rotation: -45,
                                align: 'right',
                                style: {
                                    fontFamily: '黑体',
                                    fontWeight: 'Bold'           //Times New Roman
                                }
                            },
                            categories: ['书籍1','书籍1','书籍1','书籍1','书籍1','书籍1','书籍1','书籍1','书籍1','书籍1']                        },
                        yAxis: {
                            minorTickInterval: 'auto',
                            lineColor: '#000',
                            lineWidth: 1,
                            tickWidth: 1,
                            tickColor: '#000',
                            title: {
                                text: ''
                            }
                        },
                        plotOptions: {
                            series: {
                                showCheckbox: false,
                                selected: true
//                                point: {
//                                    events: {
//                                        click: function () {
//                                        }
//                                    }
//                                }
                            },
                            line: {
                                events: {
                                    checkboxClick: function (event) {
                                        if (event.checked == true) {
                                            this.show();
                                        }
                                        else {
                                            this.hide();
                                        }
                                    },
                                    legendItemClick: function (event) {//return false 即可禁用LegendIteml，防止通过点击item显示隐藏系列
                                        return false;
                                    }
                                }
                            }
                        },
                        tooltip: {
                            valueSuffix: '次'
                        },
                        exporting: {
                            enabled:false
                        },
                        credits: {
                            enabled:false
                        },
                        series: [
                            {
                                name: '阅读次数',
                                data: reads
                            }
                        ]
                    },
                    obj: {}
                };
                $scope.grid1 = {
                    gridpagedata:{
                        nowpage:0,
                        totalpage:0,
                        totalcount:0,
                        startline:0,
                        endline:0,
                        pagesize:10,
                        datacount:0,
                        pagelist:[10],
                        toFirstpage: function(){
                            $scope.grid1.gridpagedata.nowpage = 1;
                            $scope.init();
                        },
                        toToppage: function(){
                            if($scope.grid1.gridpagedata.nowpage>1){
                                $scope.grid1.gridpagedata.nowpage--;
                            }
                            $scope.init();
                        },
                        toNextpage: function(){
                            if($scope.grid1.gridpagedata.nowpage<$scope.grid1.gridpagedata.totalpage){
                                $scope.grid1.gridpagedata.nowpage++;
                            }
                            $scope.init();
                        },
                        toLastpage: function(){
                            $scope.grid1.gridpagedata.nowpage = $scope.grid1.gridpagedata.totalpage;
                            $scope.init();
                        },
                        topage: function(){
                            if($scope.grid1.gridpagedata.nowpage<1){
                                $scope.grid1.gridpagedata.nowpage = 1;
                            }
                            if($scope.grid1.gridpagedata.nowpage>$scope.grid1.gridpagedata.totalpage){
                                $scope.grid1.gridpagedata.nowpage = $scope.grid1.gridpagedata.totalpage;
                            }
                            $scope.turnPage();
                        },
                        changePagesize: function(){
                            $scope.grid1.gridpagedata.nowpage = 1;
                            $scope.turnPage();
                        }
                    },
                    griddata: {
                        colnames: ['排名','小说名称','小说类型',"阅读次数",'阅读用户数','阅读流量(KB)','人均流量(KB)','上周排名'],
                        colmodel: [
                            { name: 'ranking', index: 'ranking', sortable: false, sorttype: 'number', align:"center"},
                            { name: 'name', index: 'name', sortable: false, sorttype: 'number', align:"center"},
                            { name: 'type', index: 'type', sortable: false, align:"center"},
                            { name: 'number', index: 'number', sortable: false, align:"center"},
                            { name: 'usernumber', index: 'usernumber', sortable: true, align:"center"},
                            { name: 'traffic', index: 'traffic', sortable: true, align:"center"},
                            { name: 'bothtraffic', index: 'bothtraffic', sortable: true, align:"center"},
                            { name: 'lastweek', index: 'lastweek', sortable: false, align:"center"}
                        ],
                        data: [
                            //{ ranking:"1", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"2"},
                            //{ ranking:"2", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"1"},
                            //{ ranking:"3", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"4"},
                            //{ ranking:"4", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"5"},
                            //{ ranking:"5", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"6"},
                            //{ ranking:"6", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"10"},
                            //{ ranking:"7", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"8"},
                            //{ ranking:"8", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"9"},
                            //{ ranking:"9", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"3"},
                            //{ ranking:"10", name:"书籍1",type:"类型1", number:"18000", usernumber:"15000", "traffic":"79309", "bothtraffic":"78309", "lastweek":"7"}
                        ]
                    },
                    obj:{},
                    shrinkToFit:true,
                    gridresize: function (grid) {
                        grid.setGridWidth($(window).width());
                        grid.setGridHeight(300);
                    }
                };
            //切换（流量，阅读次数，用户数）三个指标
            $("#index").live("change",function(){
                //alert($("#index").val());


                var option = $("#index").val();
                if(option=="user"){
                    $scope.highchartline.chartdata.tooltip.valueSuffix="人";
                $scope.highchartline.chartdata.series[0].data=users;
                    $scope.highchartline.chartdata.series[0].name="阅读用户数";
                } else if(option=="read"){
                    $scope.highchartline.chartdata.tooltip.valueSuffix="次"
                    $scope.highchartline.chartdata.series[0].data=reads;
                    $scope.highchartline.chartdata.series[0].name="阅读次数";
                } else if(option=="len"){
                    $scope.highchartline.chartdata.tooltip.valueSuffix="kb"
                    $scope.highchartline.chartdata.series[0].data=len;
                    $scope.highchartline.chartdata.series[0].name="阅读流量";
                }
                $scope.$apply();
                });
                //导出小说详情
                $scope.downL3Buness=function(){
                    if(abledown==true){
                        var url=httpservice.javaserverurl+"databuness.do?method=downDataBunessInfo"+"&starttime="+downcondition.starttime+"&endtime="+downcondition.endtime;
                        window.location.href=url;
                    }else{
                        alert("无数据下载");
                        return false;
                    }
                };
                //$scope.getrecentconditon = function(reccount){
                //    var condition = {
                //        starttime: dateFormat(new Date(new Date().setDate(new Date().getDate() -reccount)),'yyyy-MM-dd hh:mm:ss'),
                //        //endtime: dateFormat(new Date(new Date().setDate(new Date().getDate())),'yyyy-MM-dd hh:mm:ss'),
                //        endtime: dateFormat(new Date(new Date().setDate(new Date().getDate()-1)),'yyyy-MM-dd hh:mm:ss')
                //
                //    };
                //    return condition;
                //};
                $scope.selectQuery=function(recentday){
                    $("#starttime").val(dateFormat(new Date(new Date().setDate(new Date().getDate() -recentday)),'yyyy-MM-dd '));
                    $("#endtime").val(dateFormat(new Date(new Date().setDate(new Date().getDate() -1)),'yyyy-MM-dd '));
                    $scope.getdatabuness();

                };
                $scope.getcondition=function(){
                    var start=Date.parse($("#starttime").val());
                    var end=Date.parse($("#endtime").val())+1*24*60*60*1000;

                    var endtime = dateFormat(new Date(end),'yyyy-MM-dd 00:00:00');
                    var starttime  = dateFormat(new Date(start),'yyyy-MM-dd 00:00:00');
                    var condition={
                        starttime:starttime,
                        endtime:endtime
                    };
                    return condition;

                };
                $scope.getdatabuness=function(){
                    if($('#starttime').val()==""){
                        alert('请选择开始时间!');
                        return false;
                    }
                    if($('#endtime').val()==""){
                        alert('请选择结束时间!');
                        return false;
                    }
                    if(new Date($("#endtime").val())<new Date($("#starttime").val())){
                        alert('开始时间不能大于结束时间!');
                        return false;
                    }

                    var url="databuness.do?method=getDataBuness";
                    $scope.$emit('loading','true');
                    var getdatas=httpservice.javaPost(url,$scope.getcondition(),function(result){
                        $scope.grid1.griddata.data=result.datas;
                        $scope.grid1.gridpagedata.endline=result.datas.length;
                        if(result.datas.length>0){
                            $scope.grid1.gridpagedata.startline=1;
                            $scope.grid1.gridpagedata.nowpage=1;
                            $scope.grid1.gridpagedata.totalpage=1;
                            $scope.grid1.gridpagedata.totalcount=result.datas.length;
                        }else{
                            $scope.grid1.gridpagedata.startline=0;
                            $scope.grid1.gridpagedata.nowpage=0;
                            $scope.grid1.gridpagedata.totalpage=0;
                            $scope.grid1.gridpagedata.totalcount=0;
                            $("#index").val("read");

                        }
                        $scope.grid1.gridpagedata.datacount=result.datas.length;
                        abledown = result.abledown;
                        downcondition=result.condition;
                        users=result.usercount;
                        reads=result.readcount;
                        len=result.len;
                        $scope.highchartline.chartdata.tooltip.valueSuffix='次';
                        $scope.highchartline.chartdata.xAxis.categories=result.names;
                        $scope.highchartline.chartdata.series[0].name='阅读次数';
                        $("#index").val("read");
                        $scope.highchartline.chartdata.series[0].data=result.readcount;

                    });
                    $.when(getdatas).then(function(){}).always(function(){
                        $scope.$emit('loading','false')
                        $scope.$apply();
                    });

                }
            };
            var page2ctrl = function ($scope, httpservice) {
                $scope.msg = "欢迎来到Page2";
                $scope.list = [{value:'a',name:"视频"},{value:'b',name:"音乐"}];
                $scope.selected = $scope.list[0];

                $scope.init=function(){
                    httpservice.getJSON("script/Common/GetServiceType",null,function(data){
                        $scope.list = data;
                        $scope.selected = $scope.list[0];
                        $scope.$apply();
                    });
                };

//                $scope.init();

                $scope.change = function(){
                    alert($scope.selected.code+$scope.selected.name);
                    console.log($scope.selected);
                };
            };
            angular.module('dataBusiness-ctrl', [])
                .controller('HotPointBusCtrl', ['$scope', 'HttpService', hotPointBusCtrl])
                .controller('Lv3BusCtrl', ['$scope', 'HttpService', lv3BusCtrl])
                .controller('Page2Ctrl', ['$scope', 'HttpService', page2ctrl]);
            //require('WdatePicker');
        })(jQuery);
    }
});